package com.SpringBoot.location.controller;


import com.SpringBoot.Util.Result;
import com.SpringBoot.location.pojo.Location;
import com.SpringBoot.location.service.LocationService;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 用户地址表 前端控制器
 * </p>
 *
 * @author bxk
 * @since 2025-09-19
 */
@Controller
@RestController
@RequestMapping("/location")
public class LocationController {

    private final LocationService locationService;

    public LocationController(LocationService locationService) {
        this.locationService = locationService;
    }

    @PostMapping("/addLocation")
    public Result addLocation(@RequestBody Location location) {
        return locationService.addLocation(location);
    }
    @PostMapping("/updateLocation")
    public Result updateLocation(@RequestBody Location location) {
        return locationService.updateLocation(location);
    }
    @GetMapping("getLocationByUserId")
    public Result getLocationByUserId(@RequestParam("userId") Integer userId) {
        return locationService.getLocationByUserId(userId);
    }

    @PostMapping("/deleteLocation")
    public Result deleteLocation(@RequestParam Integer locationId) {
        return locationService.deleteLocation(locationId);
    }

}
